
<!DOCTYPE HTML>
<html lang="en" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Bluetooth ruler · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    


    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    
    <link rel="prev" href="ble_user_scale.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Overview
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../guide/android.html">
            
                <a href="../guide/android.html">
            
                    
                    android
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../guide/ios.html">
            
                <a href="../guide/ios.html">
            
                    
                    ios
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" >
            
                <span>
            
                    
                    work process
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="ble_scale.html">
            
                <a href="ble_scale.html">
            
                    
                    Common Bluetooth scale
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="ble_scale_custom_connect.html">
            
                <a href="ble_scale_custom_connect.html">
            
                    
                    Common Bluetooth Scale-Self-managed Bluetooth
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="kitchen_scale.html">
            
                <a href="kitchen_scale.html">
            
                    
                    Kitchen scale
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="ble_user_scale.html">
            
                <a href="ble_user_scale.html">
            
                    
                    User Scale
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.4.5" data-path="ble_ruler.html">
            
                <a href="ble_ruler.html">
            
                    
                    Bluetooth ruler
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" >
            
                <span>
            
                    
                    API
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html">
            
                    
                    QNBleApi
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1.1" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#initsdk">
            
                    
                    initSdk
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.2" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#getcursystemblestate">
            
                    
                    getCurSystemBleState
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.3" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#setsysblestatelistener">
            
                    
                    setSysBleStateListener
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.4" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#setbledevicediscoverylistener">
            
                    
                    setBleDeviceDiscoveryListener
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.5" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#setbleconnectionchangelistener">
            
                    
                    setBleConnectionChangeListener
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.6" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#setdataListener">
            
                    
                    setDataListener
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.7" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#setblekitchenlistener">
            
                    
                    setBleKitchenListener
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.8" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#setloglistener">
            
                    
                    setLogListener
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.9" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#startbledevicediscovery">
            
                    
                    startBleDeviceDiscovery
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.10" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#stopbledevicediscovery">
            
                    
                    stopBleDeviceDiscovery
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.11" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#connectdevice">
            
                    
                    connectDevice
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.12" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#connectuserscaledevice">
            
                    
                    connectUserScaleDevice
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.13" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#connectblekitchendevice">
            
                    
                    connectBleKitchenDevice
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.14" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#setblekitchendeviceconfig">
            
                    
                    setBleKitchenDeviceConfig
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.15" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#disconnectdevice">
            
                    
                    disconnectDevice
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.16" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#getconfig">
            
                    
                    getConfig
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.17" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#convertweightwithtargetunit">
            
                    
                    convertWeightWithTargetUnit
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.18" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#builddevice">
            
                    
                    buildDevice
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.19" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#buildprotocolhandler">
            
                    
                    buildProtocolHandler
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.20" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#generatescaledata">
            
                    
                    generateScaleData
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.21" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#physiquecalculation">
            
                    
                    physiqueCalculation
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.22" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#switchuserscaleuser">
            
                    
                    switchUserScaleUser
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.23" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#updateuserscaleidentifyweight">
            
                    
                    updateUserScaleIdentifyWeight
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.24" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#setblerulerlistener">
            
                    
                    setBleRulerListener
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.25" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#connectrulerdevice">
            
                    
                    connectRulerDevice
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../api/QNUser.html">
            
                <a href="../api/QNUser.html">
            
                    
                    QNUser
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../api/QNScaleData.html">
            
                <a href="../api/QNScaleData.html">
            
                    
                    QNScaleData
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../api/QNScaleStoreData.html">
            
                <a href="../api/QNScaleStoreData.html">
            
                    
                    QNScaleStoreData
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../api/QNScaleItemData.html">
            
                <a href="../api/QNScaleItemData.html">
            
                    
                    QNScaleItemData
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="../api/QNBleDevice.html">
            
                <a href="../api/QNBleDevice.html">
            
                    
                    QNBleDevice
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.7" data-path="../api/QNBleBroadcastDevice.html">
            
                <a href="../api/QNBleBroadcastDevice.html">
            
                    
                    QNBleBroadcastDevice
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.8" data-path="../api/QNBleKitchenDevice.html">
            
                <a href="../api/QNBleKitchenDevice.html">
            
                    
                    QNBleKitchenDevice
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.9" data-path="../api/QNConfig.html">
            
                <a href="../api/QNConfig.html">
            
                    
                    QNConfig
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.10" data-path="../api/QNWiFiConfig.html">
            
                <a href="../api/QNWiFiConfig.html">
            
                    
                    QNWiFiConfig
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.11" data-path="../api/QNUserScaleConfig.html">
            
                <a href="../api/QNUserScaleConfig.html">
            
                    
                    QNUserScaleConfig
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.12" data-path="../api/QNBleKitchenConfig.html">
            
                <a href="../api/QNBleKitchenConfig.html">
            
                    
                    QNBleKitchenConfig
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.13" data-path="../api/QNBleStateListener.html">
            
                <a href="../api/QNBleStateListener.html">
            
                    
                    QNBleStateListener
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.14" data-path="../api/QNBleDeviceDiscoveryListener.html">
            
                <a href="../api/QNBleDeviceDiscoveryListener.html">
            
                    
                    QNBleDeviceDiscoveryListener
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.15" data-path="../api/QNBleConnectionChangeListener.html">
            
                <a href="../api/QNBleConnectionChangeListener.html">
            
                    
                    QNBleConnectionChangeListener
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.16" data-path="../api/QNScaleDataListener.html">
            
                <a href="../api/QNScaleDataListener.html">
            
                    
                    QNScaleDataListener
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.17" data-path="../api/QNUserScaleDataListener.html">
            
                <a href="../api/QNUserScaleDataListener.html">
            
                    
                    QNUserScaleDataListener
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.18" data-path="../api/QNBleKitchenListener.html">
            
                <a href="../api/QNBleKitchenListener.html">
            
                    
                    QNBleKitchenListener
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.19" data-path="../api/QNLogListener.html">
            
                <a href="../api/QNLogListener.html">
            
                    
                    QNLogListener
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.20" data-path="../api/QNResultCallback.html">
            
                <a href="../api/QNResultCallback.html">
            
                    
                    QNResultCallback
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.21" data-path="../api/QNShareData.html">
            
                <a href="../api/QNShareData.html">
            
                    
                    QNShareData
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.22" data-path="../api/QNUtils.html">
            
                <a href="../api/QNUtils.html">
            
                    
                    QNUtils
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.23" data-path="../api/QNBleProtocolHandler.html">
            
                <a href="../api/QNBleProtocolHandler.html">
            
                    
                    QNBleProtocolHandler
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.24" data-path="../api/QNBleProtocolDelegate.html">
            
                <a href="../api/QNBleProtocolDelegate.html">
            
                    
                    QNBleProtocolDelegate
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.25" data-path="../api/QNWspScaleDataListener.html">
            
                <a href="../api/QNWspScaleDataListener.html">
            
                    
                    QNWspScaleDataListener
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.26" data-path="../api/QNBleRulerDevice.html">
            
                <a href="../api/QNBleRulerDevice.html">
            
                    
                    QNBleRulerDevice
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.27" data-path="../api/QNBleRulerData.html">
            
                <a href="../api/QNBleRulerData.html">
            
                    
                    QNBleRulerData
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.28" data-path="../api/QNBleRulerListener.html">
            
                <a href="../api/QNBleRulerListener.html">
            
                    
                    QNBleRulerListener
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" >
            
                <span>
            
                    
                    Schedule
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../attouched_list/faq.html">
            
                <a href="../attouched_list/faq.html">
            
                    
                    FAQ
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../attouched_list/body_indexes.html">
            
                <a href="../attouched_list/body_indexes.html">
            
                    
                    Body Index Constant
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../attouched_list/device_type.html">
            
                <a href="../attouched_list/device_type.html">
            
                    
                    Device Type
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../attouched_list/display_module_type.html">
            
                <a href="../attouched_list/display_module_type.html">
            
                    
                    Display module type
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../attouched_list/body_shape.html">
            
                <a href="../attouched_list/body_shape.html">
            
                    
                    Body shape comparison table
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="../attouched_list/error_code.html">
            
                <a href="../attouched_list/error_code.html">
            
                    
                    Error Code
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="../attouched_list/area_type.html">
            
                <a href="../attouched_list/area_type.html">
            
                    
                    Area Type
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.8" data-path="../attouched_list/scan_error.html">
            
                <a href="../attouched_list/scan_error.html">
            
                    
                    Scan Error Code
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.9" data-path="../attouched_list/scale_state.html">
            
                <a href="../attouched_list/scale_state.html">
            
                    
                    Scale State Definition
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.10" data-path="../attouched_list/scale_event.html">
            
                <a href="../attouched_list/scale_event.html">
            
                    
                    Scale event definition
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.11" data-path="../attouched_list/test_list.html">
            
                <a href="../attouched_list/test_list.html">
            
                    
                    Test Case
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.12" data-path="../history/history.html">
            
                <a href="../history/history.html">
            
                    
                    Update Log
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >Bluetooth ruler</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="bluetooth-ruler">Bluetooth ruler</h1>
<ul>
<li>Short press the device <code>switch key</code> to power on, long press the key;</li>
<li>Device <code>function key</code> Short press to lock the current measurement data, long press to switch the device unit.</li>
</ul>
<h2 id="bluetooth-ruler-sdk-access-steps">Bluetooth ruler SDK access steps</h2>
<h3 id="1-initialize-qnsdk">1. Initialize QNSDK</h3>
<p>Use <a href="../api/QNBleApi.html#initSdk">QNBleApi.initSdk</a> for initialization, which has been introduced in the previous article, <a href="../#Development%20process">please check</a></p>
<h3 id="second-set-the-scale-callback-listener-class">Second, set the scale callback listener class</h3>
<p>Before enabling Bluetooth scanning, you need to set the listener class, the method is <a href="../api/QNBleApi.html#setblerulerlistener">QNBleApi.setBleRulerListener</a>, this method only needs to be called once, and remember to set it to null/ nil</p>
<p>android example:</p>
<pre><code class="lang-java">QNBleApi mQNBleApi = QNBleApi.getInstance(context);
mQNBleApi.setBleRulerListener(<span class="hljs-keyword">this</span>)
</code></pre>
<p>iOS example&#xFF1A;</p>
<pre><code>QNBleApi *bleApi = [QNBleApi sharedBleApi];
bleApi.bleRulerListener = self;
</code></pre><h3 id="2-implement-the-listener-method">2. Implement the listener method</h3>
<p>In order to implement the monitoring method, QNSDK will call back the discovered settings, device link status and measurement data results to the monitoring method.</p>
<p>android example&#xFF1A;</p>
<pre><code class="lang-java">    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onRulerDeviceDiscover</span><span class="hljs-params">(QNBleRulerDevice device)</span> </span>{

    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onRulerConnecting</span><span class="hljs-params">(QNBleRulerDevice device)</span> </span>{

    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onRulerConnected</span><span class="hljs-params">(QNBleRulerDevice device)</span> </span>{

    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onGetReceiveRealTimeData</span><span class="hljs-params">(QNBleRulerData data, QNBleRulerDevice device)</span> </span>{

    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onGetReceiveResultData</span><span class="hljs-params">(QNBleRulerData data, QNBleRulerDevice device)</span> </span>{

    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onRulerDisconnected</span><span class="hljs-params">(QNBleRulerDevice device)</span> </span>{

    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onRulerConnectFail</span><span class="hljs-params">(QNBleRulerDevice device)</span> </span>{

    }
</code></pre>
<p>iOS example&#xFF1A;</p>
<pre><code>- (void)onRulerDeviceDiscover:(QNBleRulerDevice *)device {

}

- (void)onRulerConnecting:(QNBleRulerDevice *)device {

}

- (void)onRulerConnectFail:(QNBleRulerDevice *)device {

}

- (void)onRulerConnected:(QNBleRulerDevice *)device {

}

- (void)onRulerDisconnected:(QNBleRulerDevice *)device {

}

- (void)onGetReceiveRealTimeData:(QNBleRulerData *)data device:(QNBleRulerDevice *)device {

}

- (void)onGetReceiveResultData:(QNBleRulerData *)data device:(QNBleRulerDevice *)device {

}
</code></pre><h3 id="3-initiate-bluetooth-scan">3. Initiate bluetooth scan</h3>
<p>Confirm that Bluetooth is turned on, and Android needs to check the <code>location permission</code> and<code>location switch</code>. If you confirm that Bluetooth is turned on, the location permission is authorized, and the location service switch is turned on, you can start Bluetooth scanning</p>
<blockquote>
<p>After Android 6.0, targetSdkVersion&gt;= 23 App above, you need to obtain positioning permission for Bluetooth scanning, please check <a href="https://developer.android.com/guide/topics/connectivity/bluetooth-le" target="_blank">About</a>
The location service switch is not mandatory, but some phones do not turn on this switch, and the device cannot be scanned, which is related to each mobile phone system.</p>
<p>iOS13 system has added Bluetooth usage permission, you need to check whether there is usage permission, confirm that authorized and Bluetooth is turned on, start scanning</p>
</blockquote>
<p>The scanning method is <a href="../api/QNBleApi.html#startbledevicediscovery">QNBleApi.startBleDeviceDiscovery</a>,-the-scanned-device-data-will-be-called-back-in-the-<a href="../api/qnbledevicediscoverylistener.md">qnbledevicediscoverylistener</a> in the scanning interface set above.</p>
<p>In addition, some feature settings related to scanning can be set in <a href="../api/QNConfig.html">QNConfig</a>, and the content to be set has been basically covered.</p>
<p>android example&#xFF1A;</p>
<pre><code class="lang-java">QNBleApi.getInstance(context).startBleDeviceDiscovery(<span class="hljs-keyword">new</span> QNResultCallback() {
            <span class="hljs-meta">@Override</span>
            <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onResult</span><span class="hljs-params">(<span class="hljs-keyword">int</span> code, String msg)</span> </span>{
                <span class="hljs-keyword">if</span> (code != CheckStatus.OK.getCode()) {
                   ToastMaker.show(ScanActivity.<span class="hljs-keyword">this</span>,code+<span class="hljs-string">&quot;:&quot;</span>+msg);
                }
            }
        });
</code></pre>
<p>iOS example:</p>
<pre><code>[[QNBleApi sharedBleApi] startBleDeviceDiscovery:^(NSError *error) {
    if (error) {
        NSLog([NSString stringWithFormat:@&quot;&#x542F;&#x52A8;&#x626B;&#x63CF;&#x65B9;&#x6CD5;&#x5931;&#x8D25;,&#x539F;&#x56E0;: %@&quot;,error]);
    }
}];
</code></pre><h3 id="4-connect-bluetooth-ruler">4. Connect Bluetooth ruler</h3>
<p>After receiving the callback device, you can judge whether it is the device that needs to be connected (this belongs to the business logic of the APP), and if so, connect <a href="../api/QNBleApi.html#connectrulerdevice">QNBleApi.connectRulerDevice</a>.
android example:</p>
<pre><code class="lang-java">        QNBleApi.getInstance(RulerActivity.<span class="hljs-keyword">this</span>).connectRulerDevice(qnBleRulerDevice, <span class="hljs-keyword">new</span> QNResultCallback() {
            <span class="hljs-meta">@Override</span>
            <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onResult</span><span class="hljs-params">(<span class="hljs-keyword">int</span> code, String msg)</span> </span>{

            }
        });
</code></pre>
<p>iOS example:</p>
<pre><code>   [_bleApi connectRulerDevice:device callback:^(NSError *error) {

    }];
</code></pre><h3 id="5-receive-real-time-data-and-user-determined-data">5. Receive real-time data and user-determined data</h3>
<p>Data from time to time, when the SDK and the perimeter ruler establish a Bluetooth connection, the perimeter ruler will actively report the current ruler length value and unit.
The user confirms the data, when the user presses the <code>function key</code> for a short time, the scale will automatically report the length value and unit of the ruler when the user presses the <code>function key</code>.</p>
<h3 id="&#x516D;&#x3001;disconnect">&#x516D;&#x3001;Disconnect</h3>
<p>The disconnection of the gage scale can be divided into two types: the active disconnection of the SDK software and the active disconnection of the girder device. Both disconnect methods will trigger the Disconnect method of the perimeter monitor device.
SDK software actively disconnects <a href="../api/QNBleApi.html#disconnectdevice">QNBleApi.disconnectDevice</a>
android example:</p>
<pre><code class="lang-java">        QNBleApi.getInstance(RulerActivity.<span class="hljs-keyword">this</span>).disconnectDevice(mac, <span class="hljs-keyword">new</span> QNResultCallback() {
            <span class="hljs-meta">@Override</span>
            <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onResult</span><span class="hljs-params">(<span class="hljs-keyword">int</span> i, String s)</span> </span>{

            }
        });
</code></pre>
<p>iOS example:</p>
<pre><code>   [_bleApi disconnectDeviceWithMac:_ruler.mac callback:^(NSError *error) {


    }];
</code></pre>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="ble_user_scale.html" class="navigation navigation-prev navigation-unique" aria-label="Previous page: User Scale">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Bluetooth ruler","level":"1.4.5","depth":2,"next":{"title":"API","level":"1.5","depth":1,"ref":"","articles":[{"title":"QNBleApi","level":"1.5.1","depth":2,"path":"api/QNBleApi.md","ref":"api/QNBleApi.md","articles":[{"title":"initSdk","level":"1.5.1.1","depth":3,"anchor":"#initsdk","path":"api/QNBleApi.md","ref":"api/QNBleApi.md#initsdk","articles":[]},{"title":"getCurSystemBleState","level":"1.5.1.2","depth":3,"anchor":"#getcursystemblestate","path":"api/QNBleApi.md","ref":"api/QNBleApi.md#getcursystemblestate","articles":[]},{"title":"setSysBleStateListener","level":"1.5.1.3","depth":3,"anchor":"#setsysblestatelistener","path":"api/QNBleApi.md","ref":"api/QNBleApi.md#setsysblestatelistener","articles":[]},{"title":"setBleDeviceDiscoveryListener","level":"1.5.1.4","depth":3,"anchor":"#setbledevicediscoverylistener","path":"api/QNBleApi.md","ref":"api/QNBleApi.md#setbledevicediscoverylistener","articles":[]},{"title":"setBleConnectionChangeListener","level":"1.5.1.5","depth":3,"anchor":"#setbleconnectionchangelistener","path":"api/QNBleApi.md","ref":"api/QNBleApi.md#setbleconnectionchangelistener","articles":[]},{"title":"setDataListener","level":"1.5.1.6","depth":3,"anchor":"#setdataListener","path":"api/QNBleApi.md","ref":"api/QNBleApi.md#setdataListener","articles":[]},{"title":"setBleKitchenListener","level":"1.5.1.7","depth":3,"anchor":"#setblekitchenlistener","path":"api/QNBleApi.md","ref":"api/QNBleApi.md#setblekitchenlistener","articles":[]},{"title":"setLogListener","level":"1.5.1.8","depth":3,"anchor":"#setloglistener","path":"api/QNBleApi.md","ref":"api/QNBleApi.md#setloglistener","articles":[]},{"title":"startBleDeviceDiscovery","level":"1.5.1.9","depth":3,"anchor":"#startbledevicediscovery","path":"api/QNBleApi.md","ref":"api/QNBleApi.md#startbledevicediscovery","articles":[]},{"title":"stopBleDeviceDiscovery","level":"1.5.1.10","depth":3,"anchor":"#stopbledevicediscovery","path":"api/QNBleApi.md","ref":"api/QNBleApi.md#stopbledevicediscovery","articles":[]},{"title":"connectDevice","level":"1.5.1.11","depth":3,"anchor":"#connectdevice","path":"api/QNBleApi.md","ref":"api/QNBleApi.md#connectdevice","articles":[]},{"title":"connectUserScaleDevice","level":"1.5.1.12","depth":3,"anchor":"#connectuserscaledevice","path":"api/QNBleApi.md","ref":"api/QNBleApi.md#connectuserscaledevice","articles":[]},{"title":"connectBleKitchenDevice","level":"1.5.1.13","depth":3,"anchor":"#connectblekitchendevice","path":"api/QNBleApi.md","ref":"api/QNBleApi.md#connectblekitchendevice","articles":[]},{"title":"setBleKitchenDeviceConfig","level":"1.5.1.14","depth":3,"anchor":"#setblekitchendeviceconfig","path":"api/QNBleApi.md","ref":"api/QNBleApi.md#setblekitchendeviceconfig","articles":[]},{"title":"disconnectDevice","level":"1.5.1.15","depth":3,"anchor":"#disconnectdevice","path":"api/QNBleApi.md","ref":"api/QNBleApi.md#disconnectdevice","articles":[]},{"title":"getConfig","level":"1.5.1.16","depth":3,"anchor":"#getconfig","path":"api/QNBleApi.md","ref":"api/QNBleApi.md#getconfig","articles":[]},{"title":"convertWeightWithTargetUnit","level":"1.5.1.17","depth":3,"anchor":"#convertweightwithtargetunit","path":"api/QNBleApi.md","ref":"api/QNBleApi.md#convertweightwithtargetunit","articles":[]},{"title":"buildDevice","level":"1.5.1.18","depth":3,"anchor":"#builddevice","path":"api/QNBleApi.md","ref":"api/QNBleApi.md#builddevice","articles":[]},{"title":"buildProtocolHandler","level":"1.5.1.19","depth":3,"anchor":"#buildprotocolhandler","path":"api/QNBleApi.md","ref":"api/QNBleApi.md#buildprotocolhandler","articles":[]},{"title":"generateScaleData","level":"1.5.1.20","depth":3,"anchor":"#generatescaledata","path":"api/QNBleApi.md","ref":"api/QNBleApi.md#generatescaledata","articles":[]},{"title":"physiqueCalculation","level":"1.5.1.21","depth":3,"anchor":"#physiquecalculation","path":"api/QNBleApi.md","ref":"api/QNBleApi.md#physiquecalculation","articles":[]},{"title":"switchUserScaleUser","level":"1.5.1.22","depth":3,"anchor":"#switchuserscaleuser","path":"api/QNBleApi.md","ref":"api/QNBleApi.md#switchuserscaleuser","articles":[]},{"title":"updateUserScaleIdentifyWeight","level":"1.5.1.23","depth":3,"anchor":"#updateuserscaleidentifyweight","path":"api/QNBleApi.md","ref":"api/QNBleApi.md#updateuserscaleidentifyweight","articles":[]},{"title":"setBleRulerListener","level":"1.5.1.24","depth":3,"anchor":"#setblerulerlistener","path":"api/QNBleApi.md","ref":"api/QNBleApi.md#setblerulerlistener","articles":[]},{"title":"connectRulerDevice","level":"1.5.1.25","depth":3,"anchor":"#connectrulerdevice","path":"api/QNBleApi.md","ref":"api/QNBleApi.md#connectrulerdevice","articles":[]}]},{"title":"QNUser","level":"1.5.2","depth":2,"path":"api/QNUser.md","ref":"api/QNUser.md","articles":[]},{"title":"QNScaleData","level":"1.5.3","depth":2,"path":"api/QNScaleData.md","ref":"api/QNScaleData.md","articles":[]},{"title":"QNScaleStoreData","level":"1.5.4","depth":2,"path":"api/QNScaleStoreData.md","ref":"api/QNScaleStoreData.md","articles":[]},{"title":"QNScaleItemData","level":"1.5.5","depth":2,"path":"api/QNScaleItemData.md","ref":"api/QNScaleItemData.md","articles":[]},{"title":"QNBleDevice","level":"1.5.6","depth":2,"path":"api/QNBleDevice.md","ref":"api/QNBleDevice.md","articles":[]},{"title":"QNBleBroadcastDevice","level":"1.5.7","depth":2,"path":"api/QNBleBroadcastDevice.md","ref":"api/QNBleBroadcastDevice.md","articles":[]},{"title":"QNBleKitchenDevice","level":"1.5.8","depth":2,"path":"api/QNBleKitchenDevice.md","ref":"api/QNBleKitchenDevice.md","articles":[]},{"title":"QNConfig","level":"1.5.9","depth":2,"path":"api/QNConfig.md","ref":"api/QNConfig.md","articles":[]},{"title":"QNWiFiConfig","level":"1.5.10","depth":2,"path":"api/QNWiFiConfig.md","ref":"api/QNWiFiConfig.md","articles":[]},{"title":"QNUserScaleConfig","level":"1.5.11","depth":2,"path":"api/QNUserScaleConfig.md","ref":"api/QNUserScaleConfig.md","articles":[]},{"title":"QNBleKitchenConfig","level":"1.5.12","depth":2,"path":"api/QNBleKitchenConfig.md","ref":"api/QNBleKitchenConfig.md","articles":[]},{"title":"QNBleStateListener","level":"1.5.13","depth":2,"path":"api/QNBleStateListener.md","ref":"api/QNBleStateListener.md","articles":[]},{"title":"QNBleDeviceDiscoveryListener","level":"1.5.14","depth":2,"path":"api/QNBleDeviceDiscoveryListener.md","ref":"api/QNBleDeviceDiscoveryListener.md","articles":[]},{"title":"QNBleConnectionChangeListener","level":"1.5.15","depth":2,"path":"api/QNBleConnectionChangeListener.md","ref":"api/QNBleConnectionChangeListener.md","articles":[]},{"title":"QNScaleDataListener","level":"1.5.16","depth":2,"path":"api/QNScaleDataListener.md","ref":"api/QNScaleDataListener.md","articles":[]},{"title":"QNUserScaleDataListener","level":"1.5.17","depth":2,"path":"api/QNUserScaleDataListener.md","ref":"api/QNUserScaleDataListener.md","articles":[]},{"title":"QNBleKitchenListener","level":"1.5.18","depth":2,"path":"api/QNBleKitchenListener.md","ref":"api/QNBleKitchenListener.md","articles":[]},{"title":"QNLogListener","level":"1.5.19","depth":2,"path":"api/QNLogListener.md","ref":"api/QNLogListener.md","articles":[]},{"title":"QNResultCallback","level":"1.5.20","depth":2,"path":"api/QNResultCallback.md","ref":"api/QNResultCallback.md","articles":[]},{"title":"QNShareData","level":"1.5.21","depth":2,"path":"api/QNShareData.md","ref":"api/QNShareData.md","articles":[]},{"title":"QNUtils","level":"1.5.22","depth":2,"path":"api/QNUtils.md","ref":"api/QNUtils.md","articles":[]},{"title":"QNBleProtocolHandler","level":"1.5.23","depth":2,"path":"api/QNBleProtocolHandler.md","ref":"api/QNBleProtocolHandler.md","articles":[]},{"title":"QNBleProtocolDelegate","level":"1.5.24","depth":2,"path":"api/QNBleProtocolDelegate.md","ref":"api/QNBleProtocolDelegate.md","articles":[]},{"title":"QNWspScaleDataListener","level":"1.5.25","depth":2,"path":"api/QNWspScaleDataListener.md","ref":"api/QNWspScaleDataListener.md","articles":[]},{"title":"QNBleRulerDevice","level":"1.5.26","depth":2,"path":"api/QNBleRulerDevice.md","ref":"api/QNBleRulerDevice.md","articles":[]},{"title":"QNBleRulerData","level":"1.5.27","depth":2,"path":"api/QNBleRulerData.md","ref":"api/QNBleRulerData.md","articles":[]},{"title":"QNBleRulerListener","level":"1.5.28","depth":2,"path":"api/QNBleRulerListener.md","ref":"api/QNBleRulerListener.md","articles":[]}]},"previous":{"title":"User Scale","level":"1.4.4","depth":2,"path":"flow/ble_user_scale.md","ref":"flow/ble_user_scale.md","articles":[]},"dir":"ltr"},"config":{"plugins":["mermaid-gb3"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"mermaid-gb3":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"language":"en","gitbook":"*"},"file":{"path":"flow/ble_ruler.md","mtime":"2022-12-12T02:59:26.570Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2023-01-16T11:02:39.181Z"},"basePath":"..","book":{"language":"en"}});
        });
    </script>
</div>

        
    
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    <script src="../../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>

    </body>
</html>

